<h1>Editing article</h1>

<% form_for(@article) do |f| %>
  <%= f.error_messages %>
  <p>
    <%= f.text_field :title %>
    </p>

    <p>
      <%= f.text_area :content %>
      </p>
    <p>
<% Category.all.each do |e| %>
    <input type="checkbox" name="categories[]" value="<%= e.id %>" <%= "checked='checked'" if e.articles.collect{|c| c.id}.include?(@article.id) %> /><%= e.name %>
<% end %>
    </p>
  <p>
    <%= f.submit 'Update' %>
  </p>
<% end %>


<%= link_to 'Show', @article %> |
<%= link_to 'Back', articles_path %>
